package com.company.modeldesign;

import java.util.Stack;

public class MyQueue {

    private Stack<Integer> frontStack=new Stack<>();
    private Stack<Integer> backStack=new Stack<>();

    /** Initialize your data structure here. */
    public MyQueue() {

    }

    /** Push element x to the back of queue. */
    public void push(int x) {
        backStack.push(x);
    }

    /** Removes the element from in front of queue and returns that element. */
    public int pop() {
        while (backStack.size()>1){
            frontStack.push(backStack.pop());
        }
        Integer result = backStack.pop();
        while (!frontStack.isEmpty()){
            backStack.push(frontStack.pop());
        }
        return result;
    }

    /** Get the front element. */
    public int peek() {
        while (backStack.size()>1){
            frontStack.push(backStack.pop());
        }
        Integer result = backStack.pop();
        frontStack.push(result);
        while (!frontStack.isEmpty()){
            backStack.push(frontStack.pop());
        }
        return result;
    }

    /** Returns whether the queue is empty. */
    public boolean empty() {
        return backStack.isEmpty();
    }
}
